{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from random import randint\n",
    "import sys, os\n",
    "sys.path.append(\"C:\\\\Users\\\\Administrator\\\\Desktop\\\\Deeptrain\")\n",
    "os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Deeptrain.settings')\n",
    "os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'rest.settings')\n",
    "os.environ[\"DJANGO_ALLOW_ASYNC_UNSAFE\"] = \"true\"\n",
    "\n",
    "import django\n",
    "django.setup()\n",
    "\n",
    "from utils.cache import hash_cached_property\n",
    "\n",
    "\n",
    "class model(object):\n",
    "    def __init__(self):\n",
    "        self.dif = randint(0, 234) / 0.21\n",
    "\n",
    "    @hash_cached_property\n",
    "    def count(self):\n",
    "        return self.dif, randint(0, 1000000)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "outputs": [
    {
     "data": {
      "text/plain": "(<utils.cache.hash_cached_property at 0x172b8676688>,\n (995.2380952380953, 903686))"
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "model.count, model().count  # tuple(empty instance .count, instance .count)"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "outputs": [
    {
     "data": {
      "text/plain": "{(423.80952380952385, 577868)}"
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "m = model();set(m.count for i in range(10))"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "outputs": [
    {
     "data": {
      "text/plain": "2"
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def func():\n",
    "    randint(0, 234)\n",
    "    instance = model()\n",
    "    return instance.__hash__(), instance.count\n",
    "\n",
    "len(set([func() for n in range(1000)]))"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "outputs": [
    {
     "data": {
      "text/plain": "{(19.047619047619047, 933707),\n (180.95238095238096, 868891),\n (285.7142857142857, 167671),\n (423.80952380952385, 577868),\n (504.76190476190476, 16490),\n (566.6666666666667, 913430),\n (676.1904761904763, 550274),\n (723.8095238095239, 789623),\n (738.0952380952381, 519573),\n (747.6190476190476, 166494),\n (942.8571428571429, 593582),\n (952.3809523809524, 482032),\n (1071.4285714285716, 152791)}"
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "lis = []\n",
    "while len(lis) < 100000:\n",
    "    m = model()\n",
    "    lis.append(m.count)\n",
    "set(lis)"
   ],
   "metadata": {
    "collapsed": false
   }
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
